package com.aioz.security.mapper;

import com.aioz.security.entity.Position;
import com.aioz.security.entity.dto.PositionDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Aioz
 * @since 2022-09-27
 */

@Repository
public interface PositionMapper extends BaseMapper<Position> {

    List<PositionDto> getHotTopPosition();

    List<PositionDto> getPositionByCompanyId(Integer id);

    List<PositionDto> likePositionByCategory(String category);

    PositionDto getPositionDtoById(Integer id);

    @Insert("INSERT INTO sys_interest (user_id,position_id) VALUES (#{userId},#{positionId})")
    boolean userInterest(Integer positionId, Long userId);

    //查询用户是否关注该职位
    int isUserInterest(Integer positionId, Long userId);

    List<PositionDto> getInterestPositions(Long userId);

    //通过 name 模糊查询职位
    List<PositionDto> likePositionByName(String name);
}
